package com.bestcem.xm.member.enums;

import com.bestcem.xm.common.core.enums.CommonEnum;

/**
 * 需要校验的联系人字段
 *
 * @author yf.wang <yf.wang@idiaoyan.com>
 * @version V1.0
 * @date 2021/5/21
 */
public enum MemberValidateFieldEnum implements CommonEnum {

    /**
     * email
     */
    EMAIL("email", 0),

    /**
     * mobile
     */
    MOBILE("mobile", 1),

    /**
     * openid
     */
    OPEN_ID("openid", 2),

    /**
     * alipay_user_id
     */
    ALI_PAY_USER_ID("alipay_user_id", 3);


    private String name;

    private int index;

    MemberValidateFieldEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    @Override
    public int getIndex() {
        return index;
    }

    @Override
    public String getName() {
        return name;
    }


    public static MemberValidateFieldEnum getByIndex(int index) {
        MemberValidateFieldEnum[] values = MemberValidateFieldEnum.values();
        for (MemberValidateFieldEnum value : values) {
            if (value.getIndex() == index) {
                return value;
            }
        }
        return null;
    }


}
